﻿@model Fcom.VNInsurance.Web.Models.CompanyProductBenefit
@{
    ViewBag.Title = "AddCPBenefit";
    Layout = "~/Views/Shared/_CpanelLayout.cshtml";
    var companyproduct = (Fcom.VNInsurance.Web.Models.CompanyProductLang)ViewBag.companyProduct;
    var Coverage = (SelectList)ViewBag.Coveragelist;
    var Benefitlist = (SelectList)ViewBag.benefitlist;
    var companyLang = (Fcom.VNInsurance.Web.Models.CompanyLang)ViewBag.company;
}

@Html.ActionLink("Back", "CoverageCProductIDMN", "CompanyProduct", new { ID=companyproduct.CProductID},null)
<h2>ThÊm quyền lợi, sản phẩm @companyproduct.DisplayName</h2><br />
Công ty: @companyLang.CompanyName<br />

@using (Html.BeginForm()) { 
    
    <label>
        @Html.Hidden("CProductId",companyproduct.CProductID)
        Nhóm quyền lợi: @Html.DropDownList("CoverageID", Coverage)
    </label><br />
    <label>
        tên Quyền lợi: @Html.DropDownListFor(m=>m.BenefitID,Benefitlist)
    </label><br />
    <label>Số tiền bảo hiểm</label> @Html.TextBoxFor(m=>m.InsuanceMoney)
<br />
    <label>Phí bảo hiểm</label>@Html.TextBoxFor(m=>m.InsuanceFare)<br />
    <input type="submit" value="Lưu" />
}

<script>
    $(document).ready(function () {
        $("#CoverageID").change(function () {
            var id = $(this).val();
            //getbenefitsjsonbyCoverage
            $.ajax({
                type: "post",
                data: { ID: id },
                datatype: "json",
                url: "@Url.Action("getbenefitsjsonbyCoverage","CompanyProduct")",
                success: function (rvdata) {
                    $("#BenefitID").html("<option>Loadding</option>");
                    var html = "";
                    $(rvdata).each(function (index, item) {
                        html += "<option value='" + item.BenefitID + "'>" + item.DisplayName+"</option>";
                    });
                    $("#BenefitID").html(html);
                }
            })
            return false;
        });
    });
</script>